/*
 * PACKAGE NAME: com.jodinfo.outmirror.api.reportinventoryanalyze.controller
 * FILE    NAME: ReportInventoryAnalyzeDaoImpl.java
 * COPYRIGHT: Copyright(c) © 2016 heroj Company Ltd. All Rights Reserved
 */ 
package com.jodinfo.outmirror.api.reportinventoryanalyze.controller;

import java.math.BigInteger;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import com.hero.common.web.context.UserContext;
import com.hero.core.constant.SysConstant;
import com.hero.core.entity.IPlatformUser;
import com.hero.core.entity.ResponseEntity;
import com.jodinfo.outmirror.api.reportinventoryanalyze.entity.ReportInventoryAnalyzeEntity;
import com.jodinfo.outmirror.api.reportinventoryanalyze.service.ReportInventoryAnalyzeBizService;



@Controller
@RequestMapping(value = "/ReportInventoryAnalyzeAdmin")
public class ReportInventoryAnalyzeController  {
	
@Resource(name="reportInventoryAnalyzeBizService")
private ReportInventoryAnalyzeBizService ReportInventoryAnalyzeBizService;
/**
*  list数据源
* 
* */
@RequestMapping(value = "/List")
@ResponseBody
public String ReportInventoryAnalyzeList(ReportInventoryAnalyzeEntity ReportInventoryAnalyzeEntity) {
	if(ReportInventoryAnalyzeEntity==null){
		ReportInventoryAnalyzeEntity = new ReportInventoryAnalyzeEntity();
		ReportInventoryAnalyzeEntity.setPageIndex(SysConstant.DEFAULT_PAGEINDEX);
		ReportInventoryAnalyzeEntity.setPageSize(SysConstant.DEFAULT_PAGESIZE);
	}
	ReportInventoryAnalyzeEntity.setCurrentUser(UserContext.getUser());
	ReportInventoryAnalyzeEntity.setBranchOrgId(((IPlatformUser)UserContext.getUser()).getOrgId());
	ReportInventoryAnalyzeEntity.setOfficeOrgId(((IPlatformUser)UserContext.getUser()).getOrgId());
	String str = ReportInventoryAnalyzeBizService.queryListForPageReportInventoryAnalyze(ReportInventoryAnalyzeEntity);
	return str;
}
/**
* ReportInventoryAnalyzeEntity List页面
* 
* */
@RequestMapping(value = "/ListPage")
public ModelAndView ReportInventoryAnalyzeListPage(ReportInventoryAnalyzeEntity ReportInventoryAnalyzeEntity,HttpServletRequest request) {
	
	return new ModelAndView(returnPath("ReportInventoryAnalyzeList"));
}
/**
* ReportInventoryAnalyzeEntity详细页 
* 
* */
@RequestMapping(value = "/EditPage")
public ModelAndView ReportInventoryAnalyzeEditPage(ReportInventoryAnalyzeEntity ReportInventoryAnalyzeEntity) {
	
	return new ModelAndView(returnPath("ReportInventoryAnalyzeAdd"));
}
/**
 * 查询ReportInventoryAnalyzeEntity
 * 
 * */
@RequestMapping(value = "/queryByID")
public @ResponseBody String findReportInventoryAnalyzeData(HttpServletRequest request) {
	String id = request.getParameter("id");
	ReportInventoryAnalyzeEntity ReportInventoryAnalyzeEntity =  ReportInventoryAnalyzeBizService.queryById(new BigInteger(id));
	return JSON.toJSONString(ReportInventoryAnalyzeEntity); 
}

/**
 * 保存或更新ReportInventoryAnalyze 
 * 
 * */
@RequestMapping(value = "/saveReportInventoryAnalyze")
public @ResponseBody String saveReportInventoryAnalyzeData(@RequestBody ReportInventoryAnalyzeEntity ReportInventoryAnalyzeEntity) {
	ResponseEntity rs = null;
	if(ReportInventoryAnalyzeEntity!=null){
		ReportInventoryAnalyzeEntity.setCurrentUser(UserContext.getUser());
		if(ReportInventoryAnalyzeEntity.getId()!=null){
			rs = ReportInventoryAnalyzeBizService.updateReportInventoryAnalyze(ReportInventoryAnalyzeEntity);
		}else{
			rs = ReportInventoryAnalyzeBizService.addReportInventoryAnalyze(ReportInventoryAnalyzeEntity);
		}
	}
	return JSON.toJSONString(rs);
}
/**
 * 导出ReportInventoryAnalyzeEntity
 * @author weiwei
 * @date 2015-7-09  下午2:13:28
 * @return
 */
@RequestMapping(value = "/exportReportInventoryAnalyzeExcel")
public void exportReportInventoryAnalyzeExcel(ReportInventoryAnalyzeEntity ReportInventoryAnalyzeEntity,HttpServletResponse response) {
	ReportInventoryAnalyzeBizService.exportReportInventoryAnalyze(ReportInventoryAnalyzeEntity, response);
}


 /**
 * 
 * 批量删除
 * @author weiwei
 * @date 2017年3月13日 下午2:48:57
 * @param ReportInventoryAnalyzeEntity
 * @return
 */
@RequestMapping(value = "/batchDelReportInventoryAnalyze")
public @ResponseBody String batchDelReportInventoryAnalyze(ReportInventoryAnalyzeEntity ReportInventoryAnalyzeEntity) {
	ResponseEntity rs = null;
	rs = ReportInventoryAnalyzeBizService.batchDelReportInventoryAnalyze(ReportInventoryAnalyzeEntity);
	return  JSON.toJSONString(rs);
}
@RequestMapping(value = "/queryAnalyzeData")
public @ResponseBody String queryAnalyzeData(ReportInventoryAnalyzeEntity ReportInventoryAnalyzeEntity) {
	ResponseEntity rs = null;
	if(ReportInventoryAnalyzeEntity==null){
		ReportInventoryAnalyzeEntity = new ReportInventoryAnalyzeEntity();
		ReportInventoryAnalyzeEntity.setPageIndex(SysConstant.DEFAULT_PAGEINDEX);
		ReportInventoryAnalyzeEntity.setPageSize(SysConstant.DEFAULT_PAGESIZE);
	}
	ReportInventoryAnalyzeEntity.setCurrentUser(UserContext.getUser());
	if(StringUtils.isEmpty(ReportInventoryAnalyzeEntity.getBranchOrgId()) 
			&& StringUtils.isEmpty(ReportInventoryAnalyzeEntity.getOfficeOrgId())){
		ReportInventoryAnalyzeEntity.setBranchOrgId(((IPlatformUser)UserContext.getUser()).getOrgId());
		ReportInventoryAnalyzeEntity.setOfficeOrgId(((IPlatformUser)UserContext.getUser()).getOrgId());
	}
	rs = ReportInventoryAnalyzeBizService.queryAnalyzeData(ReportInventoryAnalyzeEntity);
	return  JSON.toJSONString(rs);
}

@RequestMapping(value = "/ReportInventoryAnalyzeChart")
public ModelAndView ReportInventoryAnalyzeChart() {
	return new ModelAndView(returnPath("ReportInventoryAnalyzeChart"));
}


/**
 * 定义
 * 
 */
private final String MODULE_PATH = "/reportinventoryanalyze/";

//返回路径
private String returnPath(String jspName) {
	return MODULE_PATH + jspName;
}
}
